﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BBCP.UI.Tasks;
using BBCP.Model;

namespace BBCP.UI.Customers
{
    public class DelCustomer : ITask
    {
        public bool Run()
        {
            using (var context = new NorthwindEntities())
            {
                Console.Write("Podaj ID konrahenta: ");
                var id = Console.ReadLine();

                var customer = context.Customers.SingleOrDefault(n => n.CustomerID == id);
                if (customer == null)
                {
                    Console.WriteLine("ni ma");
                    return true;
                }
                context.Customers.DeleteObject(customer);
                context.SaveChanges();
            }
            return true;
        }
    }
}
